package test4;


import java.util.Arrays;

public class StudentTest {
    public static void main(String [] args){
        Student [] stu=new Student[5];
        stu[0]=new Student(1,"tom",20,"男");
        stu[1]=new Student(3,"fox",19,"男");
        stu[2]=new Student(2,"james",21,"男");

        Arrays.sort(stu);
        for(Student s:stu){
            System.out.println("id= "+s.getId()+" name="+s.getName()+" age="+s.getSex());
        }
    }

}

class Student implements Comparable <Student>{
    private int id;
    private int age;
    private String name;
    private String sex;
    public Student(int id,String name,int age,String sex){
        this.name=name;
        this.id=id;
        this.age=age;
        this.sex=sex;
    }

//
//    public int compareTo(Student other) {
//        if(this.score<other.score) return -1;
//        else if(this.score>other.score)return 1;
//        return 0;

    }




    public int getId() {
        return id;
    }




    public String getName() {
        return name;
    }
   public double getAge(){
       return age;
   }
   public String getSex() {
	   return sex;
   }



}